package com.zhuzi.entity;

import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author zhuzi
 * 2022/7/30 20:07
 */
@Data
@Accessors(chain = true)
@Entity
@Table(name = "ths_news")
@NamedQueries({
        @NamedQuery(name = "ThsNewEntity.findByPublishTimeGreaterThanEqual", query = "select t from ThsNewEntity t where t.publishTime >= :publishTime")
})
@org.hibernate.annotations.Table(appliesTo = "ths_news", comment = "同花顺新闻")
public class ThsNewEntity extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;
    /**
     * 正股名称
     */

    @ToString.Include(rank = 2)
    @Column(columnDefinition = "varchar(10) COMMENT '正股名称'")
    private String stockNm;
    /**
     * 正股代码
     */
    @ToString.Include(rank = 3)
    @Column(columnDefinition = "varchar(10) COMMENT '正股代码'")
    private String stockId;


    /**
     * 标题
     */
    @Column(columnDefinition = "varchar(100) COMMENT '标题'")
    private String title;
    /**
     * url
     */
    @Column(columnDefinition = "varchar(100) COMMENT '新闻链接'")
    private String url;

    @Column(name = "new_content", columnDefinition = "TEXT")
    private String newContent;
    /**
     * 发布时间
     */
    @Column(columnDefinition = "datetime(4) comment'发布时间'")
    private LocalDateTime publishTime;
    /**
     * 概念 varchar(30) 生效的是30
     */
    @ToString.Include(rank = 1)
    @Column(length = 50, columnDefinition = "varchar(30) COMMENT '概念'")
    private String gn;

    @Override
    public ThsNewEntity setId(Long id) {
        super.setId(id);
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ThsNewEntity that = (ThsNewEntity) o;

        return new EqualsBuilder().appendSuper(super.equals(o)).append(url, that.url).isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37).appendSuper(super.hashCode()).append(url).toHashCode();
    }

}
